package com.hndct.util;

import com.hndct.common.result.Result;
import com.hndct.common.result.ResultEnum;

/**
 * @ProjectName: ump-mine
 * @PachageName: com.hndct.util
 * @Author: YuZhenDong
 * @Discription: TODO
 * @Date: 2019/4/13
 * ClassName: ResultUtil
 */
public class ResultUtil {
    /**
     * 功能描述:
     * @param object:
     * @Return: com.hndct.common.result.Result
     * @Auther: YuZhenDong
     * @Date: 2019/4/13
     * @Discription: 操作成功，返回数据
     */
    public static Result success(Object object) {
        Result Result = new Result();
        Result.setCode(ResultEnum.SUCCESS.getCode());
        Result.setMsg(ResultEnum.SUCCESS.getMsg());
        Result.setData(object);
        return Result;
    }

    /**
     * 功能描述:
     * @param :
     * @Return: com.hndct.common.result.Result
     * @Auther: YuZhenDong
     * @Date: 2019/4/13
     * @Discription: 操作成功不返回数据
     */
    public static Result success() {
        Result Result = new Result();
        Result.setCode(ResultEnum.SUCCESS.getCode());
        Result.setMsg(ResultEnum.SUCCESS.getMsg());
        return success();
    }

    /**
     * 功能描述:
     * @param :
     * @Return: com.hndct.common.result.Result
     * @Auther: YuZhenDong
     * @Date: 2019/4/13
     * @Discription: 返回失败信息
     */
    public static Result fail() {
        Result Result = new Result();
        Result.setCode(ResultEnum.FAIL.getCode());
        Result.setMsg(ResultEnum.FAIL.getMsg());
        return fail();
    }

    /**
     * 功能描述:
     * @param code
	* @param msg:
     * @Return: com.hndct.common.result.Result
     * @Auther: YuZhenDong
     * @Date: 2019/4/13
     * @Discription: 操作失败，返回自定义错误信息
     */
    public static Result error(int code,String msg) {
        Result Result = new Result();
        Result.setCode(code);
        Result.setMsg(msg);
        return Result;
    }

    /**
     * 功能描述:
     * @param resultEnum:
     * @Return: com.hndct.common.result.Result
     * @Auther: YuZhenDong
     * @Date: 2019/4/13
     * @Discription: 操作失败，返回错误信息
     */
    public static Result error(ResultEnum resultEnum){
        Result Result = new Result();
        Result.setCode(resultEnum.getCode());
        Result.setMsg(resultEnum.getMsg());
        return Result;
    }
}
